package org.dtrd.modules.doctor.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.mybatis.GenerateUUID;
import org.dtrd.modules.doctor.entity.bean.DoctorPatientDetail;

import java.util.Date;


/**
 * <p>
 * 医生-患者
 * </p>
 *
 * @author QR
 * @since 2021-12-17
 */
@Data
@TableName("dtrd_rl_doctor_patient")
public class DtrdRlDoctorPatient {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 患者Id
     */
    @TableField("patient_id")
    private Integer patientId;

    /**
     * 医生Id
     */
    @TableField("doctor_id")
    private Integer doctorId;

    /**
     * 医生关联患者所属分组Id
     */
    @TableField("group_id")
    private Integer groupId;

    /**
     * 机构编码
     */
    @TableField("org_code")
    private String orgCode;
    /**
     * 聊天室ID
     */
    @TableField(value = "chatroom_id", fill = FieldFill.INSERT)
    @GenerateUUID
    private String chatRoomId;

    /**
     * 是否重点关注  1是 0否
     */
    @TableField("doctor_patient_concern")
    private Integer doctorPatientConcern;

    /**
     * 关联门店Id
     */
    @TableField("store_id")
    private Integer storeId;

    /**
     * 关联门店会员卡Id
     */
    @TableField("store_card_id")
    private Integer storeCardId;

    /**
     * 状态
     */
    @TableField("doctor_patients_status")
    private Integer doctorPatientsStatus;

    /**
     * 用户推荐状态
     */
    @TableField("doctor_patients_recommend_status")
    private Integer doctorPatientsRecommendStatus;

    /**
     * 关系类型
     */
    @TableField("doctor_patients_relation_type")
    private Integer doctorPatientsRelationType;

    /**
     * 关联记录ID
     */
    @TableField("measure_record_id")
    private Integer measureRecordId;

    /**
     * 关联记录日期
     */
    @TableField("measure_record_date")
    private Date measureRecordDate;

    /**
     * 医患关系解除时间
     */
    @TableField("doctor_patients_invalid_time")
    private Date doctorPatientsInvalidTime;

    /**
     * 医生类型：1-科室主任,2-医生,3-健康管理师/护士
     */
    @TableField("doctor_type")
    private Integer doctorType;

    @TableField("create_time")
    private Date createTime;

    @TableField("update_time")
    private Date updateTime;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdRlDoctorPatient() {
    }

    public DtrdRlDoctorPatient(Integer patientId, Integer doctorId) {
        this.patientId = patientId;
        this.doctorId = doctorId;
    }

    public DtrdRlDoctorPatient init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdRlDoctorPatient parseFromDto(DoctorPatientDetail dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        doctorId = dto.getDoctorId();
        groupId = dto.getGroupId();
        orgCode = dto.getOrgCode();
        storeId = dto.getStoreId();
        storeCardId = dto.getStoreCardId();
        chatRoomId = dto.getChatRoomId();
        doctorPatientsStatus = dto.getDoctorPatientsStatus();
        doctorPatientsRecommendStatus = dto.getDoctorPatientsRecommendStatus();
        doctorPatientsRelationType = dto.getDoctorPatientsRelationType();
        doctorPatientsInvalidTime = dto.getDoctorPatientsInvalidTime();
        doctorType = dto.getDoctorType();
        return this;
    }


}
